#include <jni.h>
#include "MornDict.h"
#include <android/log.h>
#include <stdio.h>

#define LOG_TAG "MornDict"
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)

jint JNICALL Java_com_morn_dict_lib_MornDictLib_init(JNIEnv *env, jobject thiz,
		jstring path) {
	const char* str = env->GetStringUTFChars(path, 0);
	LOGI(str);

	return 1;
}

jobjectArray JNICALL Java_com_morn_dict_lib_MornDictLib_getDictInfos(
		JNIEnv *env, jobject thiz) {
	jclass clazz_date = env->FindClass("com/morn/dict/lib/model/DictInfo");
	jobjectArray dictInfos = env->NewObjectArray(2, clazz_date, NULL);
	jmethodID mid_date = env->GetMethodID(clazz_date, "<init>", "()V");
	jobject dictInfo = env->NewObject(clazz_date, mid_date);
	jfieldID id_member = env->GetFieldID(clazz_date, "wordCount", "I");
	env->SetIntField(dictInfo, id_member, 49999l);
	env->SetObjectArrayElement(dictInfos, 0, dictInfo);
	return dictInfos;

}
